<template>
  <div id="details">
    <van-cell title="采购单信息" :border="false"></van-cell>
    <van-cell-group>
    <van-field label="单号" :value="dataInfo.group_id" readonly />
    <van-field label="仓库" :value="dataInfo.target_warehouse_name" readonly />
    <van-field label="金额" :value="dataInfo.origin_amount" readonly />
    <van-field label="采购员" :value="dataInfo.buyer_name" readonly />
    </van-cell-group>
    <van-cell title="商品信息" :border="false"></van-cell>
    <van-card  v-for="item in goodsList" :key="item.id"
        :num="item.purchase_num"
        :price="item.sell_price"
        :desc="item.stock_sku"
        :title="item.name_cn"
        :thumb="item.stock_picture"
    />
  </div>
</template>

<script>
import { purchaseDetails } from '@/api/purchase.js'
export default {
  data () {
    return {
      value: '',
      goodsList: [],
      dataInfo: {
        buyer_name: '1',
        target_warehouse_name: '',
        group_id: '',
        origin_amount: ''
      }
    }
  },
  created () {
    this.purchaseDetails()
  },
  methods: {
    async purchaseDetails () {
      const res = await purchaseDetails(this.$route.query.id)
      if (res.data.code === 1) {
        this.goodsList = res.data.data.relationPurchaseOrderGoods
        this.dataInfo.buyer_name = res.data.data.buyer_name
        this.dataInfo.target_warehouse_name = res.data.data.target_warehouse_name
        this.dataInfo.group_id = res.data.data.group_id
        this.dataInfo.origin_amount = res.data.data.origin_amount
      }
    }
  }
}
</script>

<style>
  section {
    padding: 20px;
  }
  .radio_style{
     margin-left:20px;
     margin-top:5px;
  }
</style>
